/**
 * Created with IntelliJ IDEA.
 * Description:
 * https://gitee.com/li--jiaqiang/java-test.git
 * git pull
 * git pull origin master
 * git pull origin master --allow-unrelated-histories
 * User: 86187
 * Date: 2022-04-22
 * Time: 22:47
 */

//Scanner scan = new Scanner(System.in);

import java.util.Arrays;
import java.util.Scanner;

public class Test_4_22 {
    /**
     * 冒泡排序
     * @param array
     */
    public static void bubbleSort(int[] array) {
        boolean flg = false;
        for (int i = 0; i < array.length-1; i++) {
            flg = false;
            for (int j = i + 1; j < array.length; j++) {
                int tmp = 0;
                if(array[i] > array[j]) {tmp = array[i];
                    array[i] = array[j];
                    array[j] = tmp;
                    flg = true;
                }
            }
            if(flg == false) {
                break;
            }
        }

    }

    public static void main(String[] args) {
        int[] array = {3,5,7,1,6,4,25,76,45,521};
        bubbleSort(array);
        System.out.println(Arrays.toString(array));
        System.out.println();
    }
}


